package com.gitee.feizns.quickstart.ding.talk.api.v10.yida.forms.instances.advances;

import com.aliyun.dingtalkyida_1_0.Client;
import com.aliyun.dingtalkyida_1_0.models.SearchFormDataSecondGenerationHeaders;
import com.aliyun.dingtalkyida_1_0.models.SearchFormDataSecondGenerationRequest;
import com.aliyun.dingtalkyida_1_0.models.SearchFormDataSecondGenerationResponseBody;
import com.aliyun.teautil.models.RuntimeOptions;
import com.gitee.feizns.quickstart.ding.talk.client.Clients;

/**
 * 通过高级查询条件获取表单实例数据（包括子表单组件数据）
 * 通过高级查询条件获取表单实例数据（包括子表单组件数据）（/v2.0/yida/forms/instances/advances/queryAll）
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/api-searchformdatasecondgeneration-v2">通过高级查询条件获取表单实例数据（包括子表单组件数据）（/v2.0/yida/forms/instances/advances/queryAll）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/api-searchformdatasecondgeneration-v2">服务端API 宜搭应用开发 表单 通过高级查询条件获取表单实例数据（包括子表单组件数据）</a>
 * @author feizns
 * @since 2025/1/14
 */
public abstract class QueryAll {

    /**
     * 头
     * @param accessToken 访问令牌
     * @return {@link SearchFormDataSecondGenerationHeaders}
     */
    public static SearchFormDataSecondGenerationHeaders headers(String accessToken) {
        SearchFormDataSecondGenerationHeaders headers = new SearchFormDataSecondGenerationHeaders();
        headers.xAcsDingtalkAccessToken = accessToken;
        return headers;
    }

    /**
     * 执行
     * @param accessToken 访问令牌
     * @param req 要求
     * @return {@link SearchFormDataSecondGenerationResponseBody}
     * @throws Exception 例外
     */
    public static SearchFormDataSecondGenerationResponseBody execute(String accessToken, SearchFormDataSecondGenerationRequest req) throws Exception {
        Client client = Clients.create(Client.class);
        SearchFormDataSecondGenerationHeaders headers = headers(accessToken);;
        return client.searchFormDataSecondGenerationWithOptions(req, headers, new RuntimeOptions()).getBody();
    }

}
